<!-- 页面外套 -->
<div class="page-wrapper" id="personnel_company">

    <!-- 工具条组 -->
    <div class="tool-group">
        <div class="tool-deal">
            <label><button class="btn btn-primary" company-id="" id="personnel_company_structure_btn"><i class="icon icon-sitemap"></i> 组织架构表</button></label>
            <div class="clearfix"></div>
        </div>
    </div>
    <!-- tool-group -->

    <!-- 高亮区域 -->
    <div class="hl-default" style="padding:30px 35px;border:1px solid #ddd;">
        <ul class="tree-folders tree-lines" id="personnel_company_tree"></ul>
    </div>
    <!-- hl-default -->

    <!-- 组织架构表 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="personnel_company_structure_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">组织架构表</h4>
                </div>
                <div class="modal-body">
                    <div id="personnel_company_structure_dom"></div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>
    <!-- personnel_company_structure_box -->

</div>
<!-- page-wrapper -->
<script>
$(function(){
    
    //变量声明------------------------------------------------------------------------
    var
    personnel_company               = $("#personnel_company"),                  //页面ID
    personnel_company_tool_select1  = $("#personnel_company_tool_select1"),     //下拉选择
    personnel_company_structure_btn = $("#personnel_company_structure_btn"),    //架构按钮
    personnel_company_structure_box = $("#personnel_company_structure_box"),    //架构面板
    personnel_company_structure_dom = $("#personnel_company_structure_dom"),    //架构组件
    personnel_company_tree          = $("#personnel_company_tree");             //数据节点树

    //接口对象------------------------------------------------------------------------------
    if( window.STATE == "local" ){

        //本地接口
        var personnel_company_api = {
            structure : LOCAL + "Company/getdeparmentid.json",
        }

    } else if ( window.STATE == "route" ){

        //远程接口
        var personnel_company_api = {
            structure : ROUTE + "Company/getdeparmentid",
        }

    }

    //节点树--------------------------------------------------------------------------------
    //实例化
    common_tree_staff(personnel_company_tree,true,false);
    //点击选中
    personnel_company_tree.on("click","span",function(){
        personnel_company_tree.find("span").removeClass("text-primary");
        $(this).addClass("text-primary");
    });

    //架构图--------------------------------------------------------------------------------
    personnel_company_structure_btn.click(function(){
        $.ajax({
            url     : personnel_company_api.structure,
            type    : "POST",
            dataType: "json",
            data    : {},
            success : function(data){
                var data = um_json(data.data);                                      //JSON解析
                if( data.status>0 ){
                    personnel_company_structure_dom.treemap("render",data);         //架构渲染
                    personnel_company_structure_box.modal("show");                  //面板显示
                }
            }
        });
    });
    
});//预加载结尾
</script>